import logging
from config.settings import TRAIN_LOG_PATH
logger = logging.getLogger('train')


def log(now):
    logger.setLevel(level=logging.INFO)
    handler = logging.FileHandler(TRAIN_LOG_PATH + '/train_' + now + '.log')
    handler.setLevel(logging.INFO)
    formatter = logging.Formatter('%(asctime)s-%(filename)s-%(levelname)s - %(message)s')
    handler.setFormatter(formatter)

    console = logging.StreamHandler()
    console.setLevel(logging.INFO)
    console.setFormatter(formatter)

    logger.addHandler(handler)
    logger.addHandler(console)
    return logger


if __name__ == '__main__':
    logger = log('ffdas')
    logger.info("Start print log")
    logger.debug("Do something")
    logger.warning("Something maybe fail.")
    logger.info("Finish")